package com.deyou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.deyou.R;
import com.deyou.base.BaseActivity;
import com.deyou.util.AndroidUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class IdentityVerifyActivity extends BaseActivity {

    @BindView(R.id.tv_mid_title)
    TextView tvMidTitle;
    @BindView(R.id.bg_verify_status1)
    ImageView bgNoVerify;
    @BindView(R.id.bg_verify_status2)
    ImageView bgVerifying;
    @BindView(R.id.bg_verify_status3)
    ImageView bgVerifyed;
    @BindView(R.id.tv_verify_status)
    TextView tvVerifyStatus;
    @BindView(R.id.btn_to_verify)
    TextView btnToVerify;

    private int verifyStatus = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_identity_verify);
        ButterKnife.bind(this);
        verifyStatus = getIntent().getExtras().getInt("verify_status");
        initView();
    }

    @Override
    protected boolean translucentStatusBar() {
        return super.translucentStatusBar();
    }

    private void initView(){
        tvMidTitle.setText("实名认证");
        bgNoVerify.setVisibility(View.GONE);
        bgVerifying.setVisibility(View.GONE);
        bgVerifyed.setVisibility(View.GONE);
        switch (verifyStatus){
            case 0:
                btnToVerify.setVisibility(View.VISIBLE);
                bgNoVerify.setVisibility(View.VISIBLE);
                tvVerifyStatus.setText(R.string.no_verify_tip);
                break;
            case 1:
                btnToVerify.setVisibility(View.GONE);
                bgVerifying.setVisibility(View.VISIBLE);
                tvVerifyStatus.setText(R.string.verifying_tip);
                break;
            case 2:
                btnToVerify.setVisibility(View.GONE);
                bgVerifyed.setVisibility(View.VISIBLE);
                tvVerifyStatus.setText(R.string.verifyed_tip);
                break;
        }
    }

    @OnClick({R.id.iv_left_back, R.id.btn_to_verify})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_left_back:
                finish();
                break;
            case R.id.btn_to_verify:
                AndroidUtils.startNextActivityForResult(IdentityVerifyActivity.this, UploadVerifyDataActivity.class, null, 10010);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 10010){
            if (resultCode == 1){
                bgNoVerify.setVisibility(View.GONE);
                bgVerifyed.setVisibility(View.GONE);
                bgVerifying.setVisibility(View.VISIBLE);
                tvVerifyStatus.setText(R.string.verifying_tip);
                btnToVerify.setVisibility(View.GONE);
            }
        }
    }
}
